package org.codefinger.dao.impl.sql.ast;

import org.codefinger.dao.impl.SQLVisitor;
import org.codefinger.dao.impl.sql.Expression;

public class NamedParamExpression implements Expression {

	private String	name;

	public NamedParamExpression(String name) {
		super();
		this.name = name;
	}

	@Override
	public boolean matchVisit(SQLVisitor visitor) {
		if (visitor.matchParam(name)) {
			visitor.appendSQL('?');
			return true;
		}
		return false;
	}

	@Override
	public void visit(SQLVisitor visitor) {
		visitor.addParamForced(name);
		visitor.appendSQL('?');
	}
	
}
